import {
  defineComponent,
  ref,
  onMounted,
  resolveDirective,
  withDirectives,
  openBlock,
  createElementBlock,
  unref
} from "vue";
import { j as useData, b as useProp } from "./index-CEDaTd93.js";
import { u as useEchart } from "./hooks-aBG276Pf.js";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "basicRadar",
  props: {
    component: {}
  },
  setup(__props) {
    const chartEl = ref(null);
    let globalOption;
    const props = __props;
    const { updateEchart, resizeHandler } = useEchart(chartEl);
    let chartData = [];
    const dataChange = (resp, _) => {
      if (resp.status === "SUCCESS") {
        chartData = resp.afterData;
        updateData(chartData);
      }
      updateData(chartData);
    };
    useData(props.component, dataChange);
    const propValueChange = () => {
      updateData(chartData);
    };
    const { propValue } = useProp(props.component, propValueChange);
    onMounted(async () => {
      globalOption = getOption();
      updateEchart(globalOption);
    });
    const getOption = () => {
      const option = {
        title: {
          text: propValue.title.title,
          show: propValue.title.isShow
        },
        tooltip: {
          trigger: "item"
        },
        legend: {
          show: propValue.legend.isShow || false,
          top: "0%",
          left: "right",
          data: []
        },
        radar: {
          indicator: [],
          radius: propValue.area.areatop || "10%",
          axisName: {
            show: propValue.label.isShow || false
          }
        },
        series: {
          type: "radar",
          label: {
            show: propValue.series.isLabel || false,
            fontSize: propValue.series.labeSize
          },
          data: []
        }
      };
      return option;
    };
    const updateData = resp => {
      globalOption = getOption();
      globalOption.radar.indicator = resp.indicatorData;
      globalOption.series.data = resp.seriesData;
      globalOption.legend.data = resp.legendData;
      updateEchart(globalOption);
    };
    return (_ctx, _cache) => {
      const _directive_resize = resolveDirective("resize");
      return withDirectives(
        (openBlock(),
        createElementBlock(
          "div",
          {
            ref_key: "chartEl",
            ref: chartEl
          },
          null,
          512
        )),
        [[_directive_resize, unref(resizeHandler)]]
      );
    };
  }
});
export { _sfc_main as default };
